import statService from '@/api/stat/stat'

let data = new class {
  // 下载文件工具

  constructor() {

    this.mybodyin={}
    this.mybodyout={}
  }
  async getmybodyout(param){
    let res;
    res= await statService.queryInOutCount({
      fromType: param.fromType,
      toType: param.toType,
      pageSize: param.pageSize,
      pageIndex:param.pageIndex,
      fromDate: param.fromDate,
      toDate: param.toDate,
      orgcascadeid:param.orgcascadeid,
      orgId: param.orgId,
    })
    if (res.success) {
      for(let item of res.data.records){
        if(this.mybodyout[item.orgName]==undefined){
          this.mybodyout[item.orgName]=item.count
        }else {
          //字符串隐式转换成数字相加（减去负的）
          this.mybodyout[item.orgName]-=-(item.count)
        }
      }
    }
  }
  async getmybodyin(param){
    let res;
    res= await statService.queryInOutCount({
      fromType: param.fromType,
      toType: param.toType,
      pageSize: param.pageSize,
      pageIndex:param.pageIndex,
      fromDate: param.fromDate,
      toDate: param.toDate,
      orgcascadeid:param.orgcascadeid,
      orgId: param.orgId,
    })
    if (res.success) {
      for(let item of res.data.records){
        if(this.mybodyin[item.orgName]==undefined){
          this.mybodyin[item.orgName]=item.count
        }else {
          this.mybodyin[item.orgName]-=-(item.count)
        }
      }
    }
  }
}

export {
  data
}
